package com.tankbattle.model;

import com.tankbattle.util.ImageManager;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;

/**
 * 墙壁类，继承自GameObject
 */
public class Wall extends GameObject {
    private boolean breakable;  // 是否可被摧毁
    private BufferedImage wallImage;
    private BufferedImage steelWallImage;

    public Wall(int x, int y, boolean breakable) {
        // 墙壁大小为32x32，与图片尺寸一致
        super(x, y, 32, 32);
        this.breakable = breakable;

        // 加载普通墙和钢墙的图片
        wallImage = ImageManager.getInstance().getImage("wall.png");
        steelWallImage = ImageManager.getInstance().getImage("steel_wall.png");
    }
    
    @Override
    public void update(double delta) {
        // 墙壁不需要更新逻辑
    }
    
    @Override
    public void draw(Graphics2D g) {
        if (!active) return; // 非活跃墙壁不绘制
        
        // 根据墙的类型选择不同的图片
        BufferedImage image = breakable ? wallImage : steelWallImage;
        if (image != null) {
            g.drawImage(image, x, y, width, height, null);
        }
    }
    
    // Getter
    public boolean isBreakable() {
        return breakable;
    }
}
